<?php
/**
 * Created by PhpStorm.
 * User: readLine
 * Date: 2017/11/15
 * Time: 15:14
 */

namespace app\index\controller;


use think\Controller;
use think\Db;

class message extends Controller
{
    public function index(){

//        $list[0]['number'] = '1';
//        $list[0]['content'] = '爱情公寓大电影上线啦';
//        $list[0]['name'] = '爱情公寓';
//        $list[0]['date'] = '2017-11-11';
//        $list[1]['number'] = '2';
//        $list[1]['content'] = 'hello world';
//        $list[1]['name'] = '陈赫';
//        $list[1]['date'] = '2017-11-16';
//        $list[2]['number'] = '3';
//        $list[2]['content'] = '没有如果';
//        $list[2]['name'] = '胡一菲';
//        $list[2]['date'] = '2017-11-15';

        $list = Db::table('message')->select();

        $this->assign('list',$list);

        return view();
    }

    public function inputMsg(){



        $data['name'] = input('name');
        $data['content'] = input('content');
        $data['date'] = date('Y-m-d');

        $res = Db::table('message')->insert($data);
        if($res){
            $this->success('成功插入');
        }
        else{
            $this->error('插入失败');
        }
    }



}